/**
 * @package 时间转换
 * @description 将12小时制转换为24小时制
 * @author liu
 */
export const title = '时间转换'

/**
 * 哈希表
 * @param {string} s
 * @returns {string}
 */
export function timeConversion(s: string): string {
  const time = s.slice(s.length - 2, s.length)
  const newTime = s.split(':')
  newTime[newTime.length - 1] = newTime[newTime.length - 1].replace(time, '')
  if (time.toLocaleLowerCase() === 'pm' && newTime[0] !== '12') {
    newTime[0] = (Number(newTime[0]) + 12).toString()
  } else if (time.toLocaleLowerCase() === 'am' && newTime[0] === '12') {
    newTime[0] = '00'
  }
  return newTime.join(':')
}
